{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">Banner列表</li>
            <li><a href="{:url('admin/slide/add')}">添加Banner</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form layui-form-pane" action="{:url('admin/slide/index')}" method="get">
                    <div class="layui-inline">
                        <label class="layui-form-label">关键字</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{$keyword}" placeholder="请输入关键字" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                    </div>
                </form>
                <hr>
                <form action="" method="post" class="ajax-form">

                <table class="layui-table">
                    <thead>
                    <tr>
                        <th style="width: 15px;"><input type="checkbox" class="check-all"></th>
                        <th style="width: 30px;">ID</th>
                        <th>排序</th>
                        <th>Banner名称</th>
                        <th>Banner图片</th>
                        <th>时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="slide_list" id="vo"}
                    <tr>
                        <td><input type="checkbox" name="ids[]" value="{$vo.id}"></td>
                        <td>{$vo.id}</td>
                        <td><input type="text" class="layui-input" onchange="changeSortId(this)" name="sort_id" value="{$vo.sort}" altid="{$vo.id}"></td>
                        <th>{$vo.name}</th>
                        <th><img src="{$vo.image}" alt="" width="70px"></th>
                        <th>{$vo.create_time}</th>
                        <td>
                            {if condition="$vo['status']==1"}上线{else /}下线{/if}
                        </td>
                        <td>
                            <a href="{:url('admin/slide/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-mini">编辑</a>
                            <a href="{:url('admin/slide/delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-danger layui-btn-mini ajax-delete">删除</a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                    <button type="button" class="layui-btn layui-btn-danger layui-btn-small ajax-action" data-action="{:url('admin/slide/delete')}">删除</button>
                </form>

                {$slide_list->render()}
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}

<script type="text/javascript">

    function changeSortId(obj) {
        var sort_id = $(obj).val();
        var id = $(obj).attr("altid");
        $.ajax({
            type: "post",
            url: "/admin/slide/changeSort",
            data: {
                sort: sort_id,
                id: id,
            },
            dataType: 'json',
            success: function (data) {
                $(obj).val(data.sort)
            }
        });
    }





</script>
{/block}
